
document.getElementById('addBookForm').addEventListener('submit', async (e) => {
    e.preventDefault();

    const bookData = {
        title: document.getElementById('title').value.trim(),
        author: document.getElementById('author').value.trim(),
        isbn: document.getElementById('isbn').value.trim(),
        category: document.getElementById('category').value.trim(),
        totalCopies: parseInt(document.getElementById('totalCopies').value),
        availableCopies: parseInt(document.getElementById('availableCopies').value),
        description: document.getElementById('description').value.trim()
    };

    try {

        const response = await postRequest(BASE_API, bookData);
        if (response.success) {
            alert('图书新增成功！');
            window.location.href = 'index.html';
        }
    } catch (error) {
        console.error('新增图书失败：', error);
    }
});